﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ClassLibrary.DAO;
using ClassLibrary.Entity;

public partial class Admin_UserControl_ucReport_Purchase : System.Web.UI.UserControl
{
    TblCustomersDAO customersDao = new TblCustomersDAO(Global.CONNECTION_STRING);
    TblBookingDAO bookDAO = new TblBookingDAO(Global.CONNECTION_STRING);
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadCashPurchase();
        }
    }

    private void LoadCashPurchase()
    {
        string idCus = Request.QueryString["idCus"];
        DataTable customer = customersDao.GetCustomerId(Global.ConvertToInt(idCus));
        foreach (DataRow dr in customer.Rows)
        {
            txtCompany.Text = dr["Companyname"].ToString();
            txtContactNo.Text = dr["phonemobile"].ToString();
            txtName.Text = dr["CustomerFullname"].ToString();
           
        }
        // noi dung booking
        DataTable dt = bookDAO.GetBook_ByIDCustomer(Global.ConvertToInt(idCus));

        grdOrder.DataSource = dt;
        grdOrder.DataBind();
        foreach (DataRow dr in dt.Rows)
        {

            decimal discount = Convert.ToInt32(dr["Discount"].ToString());
            decimal total = Convert.ToDecimal(dr["Total"].ToString());
            lbdiscount.Text = discount.ToString("c");
            lbTotalAmount.Text = total.ToString("c");
           // lbIDOrder.Text = dr["IDOrder"].ToString();
            lbDateInvoice.Text = Convert.ToDateTime(dr["OrderDate"]).ToString("dd/MM/yyyy");
            txtIDOrder.Text = dr["IDOrder"].ToString();
            lbcustomerID.Text = dr["CustomerIndex"].ToString();
            txtSales.Text = dr["SaleRep"].ToString();
        }
        
    }
}
